package com.zp.business.controller.outpFees;

import com.zp.business.entity.outpFees.bo.OutpFeesPaymentsMoneyBo;
import com.zp.business.entity.outpFees.vo.OutpFeesPaymentsMoneyVo;
import com.zp.business.service.outpFees.IOutpFeesPaymentsMoneyService;
import com.zp.common.core.controller.BaseController;
import com.zp.common.core.entity.R;
import com.zp.common.core.validate.AddGroup;
import com.zp.common.core.validate.EditGroup;
import com.zp.common.excel.utils.ExcelUtil;
import com.zp.common.log.annotation.Log;
import com.zp.common.log.enums.BusinessType;
import com.zp.common.myBatis.core.page.PageQuery;
import com.zp.common.myBatis.core.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;

/**
 * 门诊收费支付类型方式控制器
 * 前端访问路由地址为:/finance/outpFeesPaymentsMoney
 *
 * @author zhang peng
 * @ date 2024-04-12
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/outpFeesPaymentsMoney")
public class OutpFeesPaymentsMoneyController extends BaseController {

    private final IOutpFeesPaymentsMoneyService iOutpFeesPaymentsMoneyService;

    /**
     * 查询门诊收费支付类型方式列表 (分页)
     */
//    @SaCheckPermission("finance:outpFeesPaymentsMoney:list")
    @GetMapping("/selectPage")
    public TableDataInfo<OutpFeesPaymentsMoneyVo> selectPage (OutpFeesPaymentsMoneyBo bo, PageQuery pageQuery) {
        return iOutpFeesPaymentsMoneyService.queryPageList(bo, pageQuery);
    }

    /**
     * 查询门诊收费支付类型方式列表 (不分页)
     */
//    @SaCheckPermission("finance:outpFeesPaymentsMoney:list")
    @GetMapping("/list")
    public R<List<OutpFeesPaymentsMoneyVo>> list (OutpFeesPaymentsMoneyBo bo) {
        List<OutpFeesPaymentsMoneyVo> list = iOutpFeesPaymentsMoneyService.queryList(bo);
        return R.ok(list);
    }

    /**
     * 导出门诊收费支付类型方式列表
     */
//    @SaCheckPermission("finance:outpFeesPaymentsMoney:export")
    @Log(title = "门诊收费支付类型方式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export (OutpFeesPaymentsMoneyBo bo, HttpServletResponse response) {
        List<OutpFeesPaymentsMoneyVo> list = iOutpFeesPaymentsMoneyService.queryList(bo);
        ExcelUtil.exportExcel(list, "门诊收费支付类型方式", OutpFeesPaymentsMoneyVo.class, response);
    }

    /**
     * 获取门诊收费支付类型方式详细信息
     *
     * @param outpFeesPaymentsId 主键
     */
//    @SaCheckPermission("finance:outpFeesPaymentsMoney:list")
    @GetMapping("/{outpFeesPaymentsId}")
    public R<OutpFeesPaymentsMoneyVo> getInfo (@NotNull(message = "主键不能为空") @PathVariable String outpFeesPaymentsId) {
        return R.ok(iOutpFeesPaymentsMoneyService.queryById(outpFeesPaymentsId));
    }

    /**
     * 新增门诊收费支付类型方式
     */
//    @SaCheckPermission("finance:outpFeesPaymentsMoney:add")
    @Log(title = "门诊收费支付类型方式", businessType = BusinessType.INSERT)
    @PostMapping()
    public R<Void> add (@Validated(AddGroup.class) @RequestBody OutpFeesPaymentsMoneyBo bo) {
        return toAjax(iOutpFeesPaymentsMoneyService.insertByBo(bo) ? 1 : 0);
    }

    /**
     * 修改门诊收费支付类型方式
     */
//    @SaCheckPermission("finance:outpFeesPaymentsMoney:edit")
    @Log(title = "门诊收费支付类型方式", businessType = BusinessType.UPDATE)
    @PutMapping()
    public R<Void> edit (@Validated(EditGroup.class) @RequestBody OutpFeesPaymentsMoneyBo bo) {
        return toAjax(iOutpFeesPaymentsMoneyService.updateByBo(bo) ? 1 : 0);
    }

    /**
     * 删除门诊收费支付类型方式
     *
     * @param outpFeesPaymentsIds 主键串
     */
//    @SaCheckPermission("finance:outpFeesPaymentsMoney:remove")
    @Log(title = "门诊收费支付类型方式", businessType = BusinessType.DELETE)
    @DeleteMapping("/{outpFeesPaymentsIds}")
    public R<Void> remove (@NotEmpty(message = "主键不能为空") @PathVariable String[] outpFeesPaymentsIds) {
        return toAjax(iOutpFeesPaymentsMoneyService.deleteWithValidByIds(Arrays.asList(outpFeesPaymentsIds), true) ? 1 : 0);
    }
}
